package com.stlm2.dems.dao.impl;

import com.stlm2.dems.entity.Cards;
import com.stlm2.dems.entity.CardsType;
import com.sun.org.apache.bcel.internal.generic.GOTO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Repository;

import com.stlm2.dems.entity.UserCards;
import com.stlm2.dems.dao.UserCardsDao;
import com.stlm2.core.base.impl.BaseDaoImpl;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository("userCardsDao")
public class UserCardsDaoImpl extends BaseDaoImpl<UserCards> implements UserCardsDao {
    @Override
    public List<UserCards> validCards(int userId) {
     List<UserCards> list =    selectList("validCards",userId);
        return  list;
    }

    @Override
    public List<UserCards> timeOutCards(int userId) {
        List<UserCards> list =    selectList("timeOutCards",userId);
        return  list;
    }


    @Override
    public void updateStateToDue(Integer userId) {
        update("updateStateToDue",userId);
    }


    @Override
    public UserCards getByGoodsIdAndUserId(Integer goodsId, Integer userId) {
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("goodsId",goodsId);
        map.put("userId",userId);
        return selectOne("getByGoodsIdAndUserId",map);
    }

    @Override
    public UserCards getByGoodsCategoryIdAndUserId(Integer goodsCategoryId, Integer userId) {
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("goodsCategoryId",goodsCategoryId);
        map.put("userId",userId);
        return selectOne("getByGoodsCategoryIdAndUserId",map);
    }

    @Override
    public UserCards findEntityByUserCards(UserCards userCards) {
        return selectOne("findEntityByUserCards",userCards);
    }
}